<template>
  <!-- <div>
        <h3>欢迎 {{name}}</h3>
        <a href="#" @click="quit">注销登录</a>
  </div>-->
  <div id="myBox" class="container">
    <header class="row">
      <div class="col-md-8 col-lg-8 logo text-left">
        <img src="../../../static/images/hua.jpg">
        <a href="#">LINKMAN</a>
      </div>

      <!-- <div class="col-md-4 col-lg-4 head-img" v-if="show==0">
        <a class="logout" v-on:click="login()">登录</a>
      </div>-->
      <div class="col-md-4 col-lg-4 head-img">
        <img src="../../../static/images/hua.jpg" alt="头像">
        <span>欢迎您：</span>
        <a class="username">{{username}}</a>
        <a class="logout" v-on:click="logout()">注销</a>
      </div>
    </header>
    <nav class="nav-box">
      <ul class="nav nav-tabs">
        <li class="nav-item">
          <a href="javascript:void(0)" data-toggle="tab" class="nav-link active">
            <router-link to="/home/index">Index</router-link>
          </a>
        </li>
        <li class="nav-item">
          <a href="javascript:void(0)" data-toggle="tab" class="nav-link">
            <router-link to="/home/info">Info</router-link>
          </a>
        </li>
        <li class="nav-item">
          <a href="javascript:void(0)" data-toggle="tab" class="nav-link">
            <router-link to="/home/other">Other</router-link>
          </a>
        </li>
      </ul>
    </nav>
    
    <router-view></router-view>
    <footer class="footer text-center">
      <p>Footer</p>
    </footer>
  </div>
</template>

<style>
@import "../../assets/css/index.css";
</style>


<script>
/*引入公共方法*/
import { setCookie, getCookie, delCookie } from "../../assets/js/cookie.js";
export default {
  data() {
    return {
      username: "",
      name: "",
      show: 0
    };
  },
  mounted() {
    /*页面挂载获取保存的cookie值，渲染到页面上*/
    let uname = getCookie("username");
    this.username = uname;
    /*如果cookie不存在，则跳转到登录页*/
    if (uname == "") {
      this.$router.push("/");
    }
  },
  methods: {
    logout() {
      /*删除cookie*/
      delCookie("username");
      this.$router.push("/");
    }
  }
};
</script>